package com.ruoyi.ax.service.impl;

import java.util.List;

import com.ruoyi.ax.service.IAxGoodService;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.ax.mapper.AxAccountChangeRecordMapper;
import com.ruoyi.ax.domain.AxAccountChangeRecord;
import com.ruoyi.ax.service.IAxAccountChangeRecordService;

/**
 * 积分变细Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-07
 */
@Service
public class AxAccountChangeRecordServiceImpl implements IAxAccountChangeRecordService 
{
    @Autowired
    private AxAccountChangeRecordMapper axAccountChangeRecordMapper;


    @Autowired
    private IAxGoodService iAxGoodService;

    /**
     * 查询积分变细
     * 
     * @param id 积分变细主键
     * @return 积分变细
     */
    @Override
    public AxAccountChangeRecord selectAxAccountChangeRecordById(Long id)
    {
        return axAccountChangeRecordMapper.selectAxAccountChangeRecordById(id);
    }

    /**
     * 查询积分变细列表
     * 
     * @param axAccountChangeRecord 积分变细
     * @return 积分变细
     */
    @Override
    public List<AxAccountChangeRecord> selectAxAccountChangeRecordList(AxAccountChangeRecord axAccountChangeRecord)
    {
        List<AxAccountChangeRecord> list = axAccountChangeRecordMapper.selectAxAccountChangeRecordList(axAccountChangeRecord);
        for(AxAccountChangeRecord axAccountChangeRecord1:list){
            if(axAccountChangeRecord1.getGoodId()!=null){
                axAccountChangeRecord1.setAxGood( iAxGoodService.selectAxGoodById(axAccountChangeRecord1.getGoodId()));
            }
        }
        return  list;
    }

    /**
     * 新增积分变细
     * 
     * @param axAccountChangeRecord 积分变细
     * @return 结果
     */
    @Override
    public int insertAxAccountChangeRecord(AxAccountChangeRecord axAccountChangeRecord)
    {
        axAccountChangeRecord.setCreateTime(DateUtils.getNowDate());
        return axAccountChangeRecordMapper.insertAxAccountChangeRecord(axAccountChangeRecord);
    }

    /**
     * 修改积分变细
     * 
     * @param axAccountChangeRecord 积分变细
     * @return 结果
     */
    @Override
    public int updateAxAccountChangeRecord(AxAccountChangeRecord axAccountChangeRecord)
    {
        axAccountChangeRecord.setUpdateTime(DateUtils.getNowDate());
        return axAccountChangeRecordMapper.updateAxAccountChangeRecord(axAccountChangeRecord);
    }

    /**
     * 批量删除积分变细
     * 
     * @param ids 需要删除的积分变细主键
     * @return 结果
     */
    @Override
    public int deleteAxAccountChangeRecordByIds(Long[] ids)
    {
        return axAccountChangeRecordMapper.deleteAxAccountChangeRecordByIds(ids);
    }

    /**
     * 删除积分变细信息
     * 
     * @param id 积分变细主键
     * @return 结果
     */
    @Override
    public int deleteAxAccountChangeRecordById(Long id)
    {
        return axAccountChangeRecordMapper.deleteAxAccountChangeRecordById(id);
    }
}
